# Flask: 中央登记中心
from flask import Flask,request
from flask import render_template
# id和name的区别
# id用来查询标签，不具备查询的过程

# 调用自定义模块中的函数
from research import research4letters
from data import goods_list


app = Flask(__name__)
# 【GET】
@app.route('/',methods=['GET'])
def hello_world():
    return render_template('hello.html')

# ————————————————名字全称应用———————————————————
@app.route('/index',methods=['GET'])
def index():
    return render_template('index.html')

# 【POST】 实现用户输入, 点击提交，将数据提交到 /result
@app.route('/result',methods=['POST'])
def result():
    py_firstname = request.form['firstname']
    py_lastname = request.form['lastname']
    py_fullname = py_firstname.title()+' '+py_lastname.title()
    return render_template('index.html',
                           fullname = py_fullname,)

# ————————————————元音字母词频统计———————————————————

@app.route('/turn',methods=['GET'])
def turn():
    return render_template('turn.html')

# 【POST】 实现用户输入, 点击提交，将数据提交到 /result
@app.route('/words',methods=['POST'])
def times():
    py_vowels = request.form['vowels']
    py_word = request.form['word']
    py_found = research4letters(py_vowels,py_word)
    return render_template('turn.html',
                           found = py_found)

# 购物车
user_shopping_cart = []

@app.route('/register')
def register():
    return render_template('register.html')

@app.route('/goods',methods=['GET','POST'])
def goods():
    return render_template('goods.html', goods_list=goods_list)

@app.route('/last',methods=['GET','POST'])
def last():
    return render_template('last.html')


if __name__ == '__main__':
    app.run(host='127.0.0.1',port=5000,debug=True)

